package org.example.Controller;

import org.example.Dao.PermissionDao;
import org.example.Pojo.Permission;
import org.example.Pojo.PermissionSingle;
import org.example.Service.Impl.PRViewImpl;
import org.example.Service.Impl.PermissionServiceImpl;
import org.example.Service.Impl.PermissionSingleServiceImpl;
import org.example.Service.PermissionSingleService;
import org.example.Utils.RequirePermission;
import org.example.Utils.UnionResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/Permission")
public class PermissionController {
    @Autowired
    PermissionSingleServiceImpl permissionSingleServiceImpl;
    @Autowired
    PRViewImpl prViewImpl;

    @RequirePermission("m:permission")
    @RequestMapping("/GetPRView")
    public UnionResult GetPRView() {
        return prViewImpl.GetList();
    }
    @RequirePermission("m:permission")
    @RequestMapping("/removeRp")
    public UnionResult removeRp(String puid,String ruid) {
        return prViewImpl.Remove(puid,ruid);
    }
    @RequirePermission("m:permission")
    @RequestMapping("/addRp")
    public UnionResult addRp(String puid,String ruid) {
        return prViewImpl.add(puid,ruid);
    }
    @RequirePermission("m:permission")
    @RequestMapping("/updateUr")
    public UnionResult updateUr(String uuid,String ruid) {
        return prViewImpl.updateUR(ruid,uuid);
    }

    @RequirePermission("m:permission")
    @RequestMapping("/GetAllPermission")
    public UnionResult GetAllPermission() {
        return permissionSingleServiceImpl.GetAllPermissions();
    }

    @RequirePermission("m:permission")
    @RequestMapping("/AddPermission")
    public UnionResult AddPermission(PermissionSingle permission) {
        return permissionSingleServiceImpl.AddPermission(permission);
    }

    @RequirePermission("m:permission")
    @RequestMapping("/DeletePermission")
    public UnionResult DeletePermission(PermissionSingle permission) {
        return permissionSingleServiceImpl.DeletePermission(permission);
    }

    @RequirePermission("m:permission")
    @RequestMapping("/UpdatePermission")
    public UnionResult UpdatePermission(PermissionSingle permission) {
        return permissionSingleServiceImpl.UpdatePermission(permission);
    }


}
